home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1994 November / Cd Ware (Nro. 2) - Epimundo.iso / DOS / DB / DGROUP.ZIP / VIEWSTAT.PRG < prev   
Encoding:
Text File  |  1993-11-04  |  3.1 KB  |  81 lines

  1. // 
  2. // viewstatic() - version 1.0
  3. // 
  4. // Allows for viewing of the values which are stored in the Memvar Table
  5. // end of DGROUP, where Clipper static variables and ITEMs stored through 
  6. // ITEM.API are actually stored.
  7. // 
  8. // Copyright(C) 1993, Robert G. Montgomery.  All Rights Reserved.
  9. //
  10. // You are hereby granted rights to include this function in your application
  11. // programs, free of charge, and if deemed necessary, you may also distribute
  12. // the source for the function with the source for any applications which use
  13. // them, free of charge.
  14. //
  15. // This program is useful for debugging applications which call functions
  16. // which allocate ITEMs through ITEM.API and forget to release them.  Such
  17. // buggy routines will cause the number of Memvar Table values to increase
  18. // each time the buggy routine is executed.  Only routines written in C or
  19. // ASM can allocate items, which includes most third party libraries.  This 
  20. // function allows you to see what values are being lost, which can be very 
  21. // useful in determining what is losing them, and where.
  22. // 
  23. // viewstatic() takes no parameters, and returns NIL when completed.  It 
  24. // calls the functions DG_statics() and DG_stathex() to get the Memvar 
  25. // Table information to be displayed, and it calls achoice() without a user
  26. // function, so default achoice() keystroke behavior is used.  Therefore,
  27. // press <Esc> or <Enter> when finished viewing the list.
  28. //
  29. // Note that DG_statics() and DG_stathex() are C functions included with
  30. // DGROUP.ZIP which access UNDOCUMENTED internals in CLIPPER.LIB.  I only
  31. // know that they work with Clipper 5.2c, and I assume that they work with
  32. // Clipper 5.0 - 5.2c.  They probably will not work with some future version
  33. // of Clipper, so do not write programs which depend on them.  Use them with
  34. // caution.
  35. //
  36.  
  37. procedure viewstatic
  38.   local values := DG_statics()
  39.   local hexdumps := DG_stathex()
  40.   local ii_end, ttmp
  41.   local view_array := {}
  42.   local ss := savescreen()
  43.   local counter := 1, disp_count
  44.   ii_end := len(values)
  45.   clear screen
  46.   @ 0, 1 say "Memvar Table, listing Clipper static variables and allocated ITEMs."
  47.   @ 1, 0, 24, 79 box B_SINGLE
  48.   @ 1,  6 say "VALUE in Hex. "
  49.   @ 1, 37 say "Stored Value "
  50.   for ii := 1 to ii_end
  51.     if hexdumps[ii]==nil
  52.       ttmp := str(counter++,4)+'│XXXXXXXXXXXXXXXXXXXXXXXXXXXX│'+valtype(values[ii])+'│'
  53.     else
  54.       ttmp := str(counter++,4)+'│'+hexdumps[ii]+'│'+valtype(values[ii])+'│'
  55.     endif
  56.     if valtype(values[ii])=='C'
  57.       ttmp+=left(values[ii],40)
  58.     elseif valtype(values[ii])=='B'
  59.       ttmp+='{|| ... }'
  60.     elseif valtype(values[ii])=='A'
  61.       ttmp+='{ ... }'
  62.     elseif valtype(values[ii])=='N'
  63.       ttmp+=str(values[ii])
  64.     elseif valtype(values[ii])=='L'
  65.       ttmp+=iif(values[ii],'.T.','.F.')
  66.     elseif valtype(values[ii])=='D'
  67.       ttmp+=dtoc(values[ii])
  68.     endif
  69.     aadd(view_array,ttmp)
  70.   next
  71.   ttmp := disp_count := dispcount()
  72.   do while (ttmp--)>0
  73.     dispend()
  74.   enddo
  75.   achoice(2,1,23,78,view_array)
  76.   do while (disp_count--)>0
  77.     dispbegin()
  78.   enddo
  79.   restscreen(,,,,ss)
  80.   return
  81.